package top.tangyh.lamp.care.mapper;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import top.tangyh.basic.base.mapper.SuperMapper;
import top.tangyh.lamp.care.entity.BDocRecord;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * Mapper 接口
 * 文书记录表
 * </p>
 *
 * @author zqb
 * @date 2024-07-29 14:16:16
 * @create [2024-07-29 14:16:16] [zqb] [代码生成器生成]
 */
@Repository
public interface BDocRecordMapper extends SuperMapper<BDocRecord> {

    default List<BDocRecord> queryAll(String patientIdent, Integer type, String wardIdent, Date startTime, Date endTime) {
        LambdaQueryWrapper<BDocRecord> lambdaQueryWrapper = new LambdaQueryWrapper();
        lambdaQueryWrapper.eq(StrUtil.isNotBlank(patientIdent), BDocRecord::getPatientIdent, patientIdent);
        lambdaQueryWrapper.eq(null != type, BDocRecord::getType, type);
        lambdaQueryWrapper.eq(StrUtil.isNotBlank(wardIdent), BDocRecord::getWardIdent, wardIdent);
        lambdaQueryWrapper.ge(null != startTime, BDocRecord::getCreatedTime, startTime);
        lambdaQueryWrapper.le(null != endTime, BDocRecord::getCreatedTime, endTime);
        lambdaQueryWrapper.orderByDesc(BDocRecord::getCreatedTime);
        return selectList(lambdaQueryWrapper);
    }

    default List<BDocRecord> queryOne(String patientIdent, Integer type) {
        LambdaQueryWrapper<BDocRecord> lambdaQueryWrapper = new LambdaQueryWrapper();
        lambdaQueryWrapper.eq(StrUtil.isNotBlank(patientIdent), BDocRecord::getPatientIdent, patientIdent);
        lambdaQueryWrapper.eq(null != type, BDocRecord::getType, type);
        lambdaQueryWrapper.orderByDesc(BDocRecord::getCreatedTime);
        lambdaQueryWrapper.orderByDesc(BDocRecord::getUpdatedTime);
        return selectList(lambdaQueryWrapper);
    }


}


